package com.hmall.search.controller;

import com.hmall.common.domain.PageDTO;
import com.hmall.search.domain.po.ItemDoc;
import com.hmall.search.domain.query.ItemPageQuery;
import com.hmall.search.service.ISearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zzw
 * @date 2025/6/25
 * @description 搜索服务接口
 */
@Api(tags = "搜索服务接口")
@RestController
@RequestMapping("/search")
@RequiredArgsConstructor
public class SearchController {

    private final ISearchService searchService;

    @ApiOperation(value = "搜索商品列表")
    @GetMapping("/list")
    public PageDTO<ItemDoc> search(ItemPageQuery query) {
        return searchService.search(query);
    }


    @ApiOperation(value = "搜索自动补全")
    @GetMapping("/suggestion")
    public List<String> searchSuggestion(String key) {
        return searchService.searchSuggestion(key);
    }
}
